/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.application.Platform
 *  javafx.beans.value.ChangeListener
 *  javafx.beans.value.ObservableValue
 *  javafx.collections.FXCollections
 *  javafx.collections.ObservableList
 *  javafx.event.EventHandler
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.ComboBox
 *  javafx.scene.control.RadioButton
 *  javafx.scene.control.TextField
 *  javafx.scene.input.KeyCode
 *  javafx.scene.input.KeyEvent
 *  javafx.scene.layout.AnchorPane
 *  javafx.stage.Modality
 *  javafx.stage.Stage
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.acceptPo;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gys.GysApplication;
import com.gys.common.business.AcceptUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.data.KeyValue;
import com.gys.common.util.CommonUtil;
import com.gys.common.util.ConstUtil;
import com.gys.common.util.SpringUtil;
import com.gys.controller.BaseController;
import com.gys.controller.acceptPo.AcceptPoController;
import com.gys.controller.acceptPo.AddAcceptPoController;
import com.gys.controller.acceptPo.AddPoController;
import com.gys.controller.index.IndexController;
import com.gys.data.accept.AcceptInData;
import com.gys.data.accept.GetSupOutData;
import com.gys.view.acceptPo.AddPoView;
import com.gys.view.acceptPo.AddTypeView;
import com.gys.view.acceptPo.AddView;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Timer;
import java.util.TimerTask;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.ComboBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class AddTypeController
extends BaseController
implements Initializable {
    private final int pageSize = ConstUtil.DEFAULT_PAGESIZE;
    private final int defaultPageCount = ConstUtil.DEFAULT_PAGECOUNT;
    @FXML
    private AnchorPane pane;
    @FXML
    private RadioButton typeOne;
    @FXML
    private RadioButton typeTwo;
    @FXML
    private ComboBox<KeyValue> store;
    @FXML
    private TextField productCode;
    @FXML
    private TextField productName;
    @Autowired
    private AcceptPoController acceptPoController;
    @Autowired
    private AddAcceptPoController addAcceptPoController;
    @Autowired
    private AddPoController addPoController;
    @Autowired
    private IndexController indexController;
    public String type = "0";
    private ObservableList<KeyValue> storeOptions;

    public void initialize(URL location, ResourceBundle resources) {
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.pane)) {
            return;
        }
        new Timer().schedule(new TimerTask(){

            @Override
            public void run() {
                AddTypeView view = SpringUtil.getBean(AddTypeView.class);
                Stage stage = (Stage)view.getView().getScene().getWindow();
                stage.getScene().setOnKeyReleased((EventHandler)new EventHandler<KeyEvent>(){

                    public void handle(KeyEvent event) {
                        if (event.getCode() == KeyCode.ENTER) {
                            AddTypeController.this.saveAdd();
                            return;
                        }
                        if (event.getCode() == KeyCode.ESCAPE) {
                            AddTypeController.this.closeWindows();
                            return;
                        }
                    }
                });
            }
        }, 1000L);
        AcceptInData inDataStore = new AcceptInData();
        HttpJson httpJsonS = AcceptUtil.getSup(inDataStore);
        List<GetSupOutData> items = new ArrayList();
        if (!httpJsonS.isSuccess()) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", httpJsonS.getMsg());
            alert.showAndWait();
            return;
        }
        items = JSON.parseArray((String)httpJsonS.getMsg(), GetSupOutData.class);
        ArrayList<KeyValue> storeOptionList = new ArrayList<KeyValue>();
        for (GetSupOutData item : items) {
            storeOptionList.add(new KeyValue(item.getSupName(), item.getSupCode()));
        }
        this.storeOptions = FXCollections.observableArrayList(storeOptionList);
        this.store.setItems(this.storeOptions);
        CommonUtil.comboxInit(this.store);
        this.typeOne.setSelected(true);
        this.typeTwo.setSelected(false);
        this.store.setValue(null);
        this.productCode.setText("");
        this.productCode.textProperty().addListener(new ChangeListener(){

            public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                String value = AddTypeController.this.productCode.getText();
                AcceptInData inData = new AcceptInData();
                inData.setGsadProId(value);
                HttpJson httpJsonS = AcceptUtil.proInfo(inData);
                String proName = "";
                if (!httpJsonS.isSuccess()) {
                    Alert alert = AddTypeController.this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", httpJsonS.getMsg());
                    alert.showAndWait();
                    return;
                }
                proName = httpJsonS.getMsg();
                AddTypeController.this.productName.setText(proName);
            }
        });
    }

    @FXML
    private void oneAction() {
        this.typeTwo.setSelected(false);
        if (this.typeOne.isSelected()) {
            this.store.setDisable(false);
            this.productCode.setDisable(false);
            this.type = "0";
        } else {
            this.store.setDisable(true);
            this.productCode.setDisable(true);
            this.type = "1";
        }
    }

    @FXML
    private void twoAction() {
        this.typeOne.setSelected(false);
        if (this.typeTwo.isSelected()) {
            this.store.setDisable(true);
            this.productCode.setDisable(true);
            this.type = "1";
        } else {
            this.store.setDisable(false);
            this.productCode.setDisable(false);
            this.type = "0";
        }
    }

    @FXML
    private void saveAdd() {
        Platform.runLater((Runnable)new Runnable(){

            @Override
            public void run() {
                if ("0".equals(AddTypeController.this.type)) {
                    if (ObjectUtil.isEmpty(AddTypeController.this.store.getValue())) {
                        Alert alert = AddTypeController.this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u8bf7\u9009\u62e9\u4f9b\u5e94\u5546\uff01");
                        alert.showAndWait();
                        return;
                    }
                    if (ObjectUtil.isEmpty(AddTypeController.this.productCode.getText())) {
                        Alert alert = AddTypeController.this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u8bf7\u586b\u5199\u5546\u54c1\u7f16\u7801\uff01");
                        alert.showAndWait();
                        return;
                    }
                    if (ObjectUtil.isEmpty(AddTypeController.this.productName.getText())) {
                        Alert alert = AddTypeController.this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u586b\u5199\u7684\u5546\u54c1\u7f16\u7801\u4e0d\u5b58\u5728\uff01");
                        alert.showAndWait();
                        return;
                    }
                    AddTypeController.this.addAcceptPoController.init();
                    GysApplication.showView(AddView.class, (Modality)Modality.APPLICATION_MODAL);
                } else {
                    AddTypeController.this.addPoController.init();
                    GysApplication.showView(AddPoView.class, (Modality)Modality.APPLICATION_MODAL);
                }
                AddTypeController.this.pane.getScene().getWindow().hide();
            }
        });
    }

    @FXML
    private void closeWindows() {
        this.pane.getScene().getWindow().hide();
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public int getDefaultPageCount() {
        return this.defaultPageCount;
    }

    public AnchorPane getPane() {
        return this.pane;
    }

    public RadioButton getTypeOne() {
        return this.typeOne;
    }

    public RadioButton getTypeTwo() {
        return this.typeTwo;
    }

    public ComboBox<KeyValue> getStore() {
        return this.store;
    }

    public TextField getProductCode() {
        return this.productCode;
    }

    public TextField getProductName() {
        return this.productName;
    }

    public AcceptPoController getAcceptPoController() {
        return this.acceptPoController;
    }

    public AddAcceptPoController getAddAcceptPoController() {
        return this.addAcceptPoController;
    }

    public AddPoController getAddPoController() {
        return this.addPoController;
    }

    public IndexController getIndexController() {
        return this.indexController;
    }

    public String getType() {
        return this.type;
    }

    public ObservableList<KeyValue> getStoreOptions() {
        return this.storeOptions;
    }

    public void setPane(AnchorPane pane) {
        this.pane = pane;
    }

    public void setTypeOne(RadioButton typeOne) {
        this.typeOne = typeOne;
    }

    public void setTypeTwo(RadioButton typeTwo) {
        this.typeTwo = typeTwo;
    }

    public void setStore(ComboBox<KeyValue> store) {
        this.store = store;
    }

    public void setProductCode(TextField productCode) {
        this.productCode = productCode;
    }

    public void setProductName(TextField productName) {
        this.productName = productName;
    }

    public void setAcceptPoController(AcceptPoController acceptPoController) {
        this.acceptPoController = acceptPoController;
    }

    public void setAddAcceptPoController(AddAcceptPoController addAcceptPoController) {
        this.addAcceptPoController = addAcceptPoController;
    }

    public void setAddPoController(AddPoController addPoController) {
        this.addPoController = addPoController;
    }

    public void setIndexController(IndexController indexController) {
        this.indexController = indexController;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setStoreOptions(ObservableList<KeyValue> storeOptions) {
        this.storeOptions = storeOptions;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof AddTypeController)) {
            return false;
        }
        AddTypeController other = (AddTypeController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        if (this.getPageSize() != other.getPageSize()) {
            return false;
        }
        if (this.getDefaultPageCount() != other.getDefaultPageCount()) {
            return false;
        }
        AnchorPane this$pane = this.getPane();
        AnchorPane other$pane = other.getPane();
        if (this$pane == null ? other$pane != null : !this$pane.equals(other$pane)) {
            return false;
        }
        RadioButton this$typeOne = this.getTypeOne();
        RadioButton other$typeOne = other.getTypeOne();
        if (this$typeOne == null ? other$typeOne != null : !this$typeOne.equals(other$typeOne)) {
            return false;
        }
        RadioButton this$typeTwo = this.getTypeTwo();
        RadioButton other$typeTwo = other.getTypeTwo();
        if (this$typeTwo == null ? other$typeTwo != null : !this$typeTwo.equals(other$typeTwo)) {
            return false;
        }
        ComboBox<KeyValue> this$store = this.getStore();
        ComboBox<KeyValue> other$store = other.getStore();
        if (this$store == null ? other$store != null : !this$store.equals(other$store)) {
            return false;
        }
        TextField this$productCode = this.getProductCode();
        TextField other$productCode = other.getProductCode();
        if (this$productCode == null ? other$productCode != null : !this$productCode.equals(other$productCode)) {
            return false;
        }
        TextField this$productName = this.getProductName();
        TextField other$productName = other.getProductName();
        if (this$productName == null ? other$productName != null : !this$productName.equals(other$productName)) {
            return false;
        }
        AcceptPoController this$acceptPoController = this.getAcceptPoController();
        AcceptPoController other$acceptPoController = other.getAcceptPoController();
        if (this$acceptPoController == null ? other$acceptPoController != null : !(this$acceptPoController).equals(other$acceptPoController)) {
            return false;
        }
        AddAcceptPoController this$addAcceptPoController = this.getAddAcceptPoController();
        AddAcceptPoController other$addAcceptPoController = other.getAddAcceptPoController();
        if (this$addAcceptPoController == null ? other$addAcceptPoController != null : !(this$addAcceptPoController).equals(other$addAcceptPoController)) {
            return false;
        }
        AddPoController this$addPoController = this.getAddPoController();
        AddPoController other$addPoController = other.getAddPoController();
        if (this$addPoController == null ? other$addPoController != null : !(this$addPoController).equals(other$addPoController)) {
            return false;
        }
        IndexController this$indexController = this.getIndexController();
        IndexController other$indexController = other.getIndexController();
        if (this$indexController == null ? other$indexController != null : !(this$indexController).equals(other$indexController)) {
            return false;
        }
        String this$type = this.getType();
        String other$type = other.getType();
        if (this$type == null ? other$type != null : !this$type.equals(other$type)) {
            return false;
        }
        ObservableList<KeyValue> this$storeOptions = this.getStoreOptions();
        ObservableList<KeyValue> other$storeOptions = other.getStoreOptions();
        return !(this$storeOptions == null ? other$storeOptions != null : !this$storeOptions.equals(other$storeOptions));
    }

    protected boolean canEqual(Object other) {
        return other instanceof AddTypeController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        result = result * 59 + this.getPageSize();
        result = result * 59 + this.getDefaultPageCount();
        AnchorPane $pane = this.getPane();
        result = result * 59 + ($pane == null ? 43 : $pane.hashCode());
        RadioButton $typeOne = this.getTypeOne();
        result = result * 59 + ($typeOne == null ? 43 : $typeOne.hashCode());
        RadioButton $typeTwo = this.getTypeTwo();
        result = result * 59 + ($typeTwo == null ? 43 : $typeTwo.hashCode());
        ComboBox<KeyValue> $store = this.getStore();
        result = result * 59 + ($store == null ? 43 : $store.hashCode());
        TextField $productCode = this.getProductCode();
        result = result * 59 + ($productCode == null ? 43 : $productCode.hashCode());
        TextField $productName = this.getProductName();
        result = result * 59 + ($productName == null ? 43 : $productName.hashCode());
        AcceptPoController $acceptPoController = this.getAcceptPoController();
        result = result * 59 + ($acceptPoController == null ? 43 : ($acceptPoController).hashCode());
        AddAcceptPoController $addAcceptPoController = this.getAddAcceptPoController();
        result = result * 59 + ($addAcceptPoController == null ? 43 : ($addAcceptPoController).hashCode());
        AddPoController $addPoController = this.getAddPoController();
        result = result * 59 + ($addPoController == null ? 43 : ($addPoController).hashCode());
        IndexController $indexController = this.getIndexController();
        result = result * 59 + ($indexController == null ? 43 : ($indexController).hashCode());
        String $type = this.getType();
        result = result * 59 + ($type == null ? 43 : $type.hashCode());
        ObservableList<KeyValue> $storeOptions = this.getStoreOptions();
        result = result * 59 + ($storeOptions == null ? 43 : $storeOptions.hashCode());
        return result;
    }

    public String toString() {
        return "AddTypeController(pageSize=" + this.getPageSize() + ", defaultPageCount=" + this.getDefaultPageCount() + ", pane=" + this.getPane() + ", typeOne=" + this.getTypeOne() + ", typeTwo=" + this.getTypeTwo() + ", store=" + this.getStore() + ", productCode=" + this.getProductCode() + ", productName=" + this.getProductName() + ", acceptPoController=" + this.getAcceptPoController() + ", addAcceptPoController=" + this.getAddAcceptPoController() + ", addPoController=" + this.getAddPoController() + ", indexController=" + this.getIndexController() + ", type=" + this.getType() + ", storeOptions=" + this.getStoreOptions() + ")";
    }
}

